<template>
	<view>
		<view class="nav">
			<view @click="back"> ← 返回</view>
			<view>增加报修</view>
		</view>
		<view class="content_abx">
			<view>报修主题</view>
			<input type="text" placeholder="请输入" v-model="bxs.title">
		</view>
		<view class="content_a">
			<view>
				报修内容
			</view>
		</view>
		<view class="content_abx">
			<view>位置</view>
			<input type="text" placeholder="请输入" v-model="bxs.fh">
		</view>
		<view class="bz">
			<textarea placeholder="输入内容" v-model="bxs.msg"></textarea>
		</view>
		<view class="tj">
			<button @click="addbx">提交</button>
		</view>
	</view>
</template>

<script>
	import { reactive,toRefs} from 'vue'
	import http from '../../../utils/http.js'
	import store from '../../../store/index.js'
	export default {
		setup(){
			let data = reactive({
				bxs:{
					title:'',
					fh:'',
					msg:''
				},
				back:()=>{
					uni.navigateBack({
						delta: 1
					})
				},
				addbx:()=>{
					const date = new Date()
					const time = date.getFullYear()+'-'+(date.getMonth()<10?'0'+(date.getMonth()+1):date.getMonth()+1)+'-'+(date.getDate()<10?'0'+date.getDate():date.getDate())
					http({
						url:'/users/addbx',
						method:'post',
						data:{
							fh:data.bxs.fh,
							title:data.bxs.title,
							name:store.getters.getUser.guanli_hymc,
							time:time
						}
					}).then((e)=>{
						wx.showToast({
						  title: '提交成功',
						  icon:'success',
						  duration: 2000
						})
						setTimeout(()=>{
							uni.navigateBack({
								delta: 1
							})
						},2000)
					})
				}
			})
			return {...toRefs(data)}
		}
	}
</script>

<style scoped lang="less">
.nav{
	padding-top: 60rpx;
	padding-bottom: 20rpx;
	background-color: #F8F8F8;
	display: flex;
	position: relative;
	justify-content: center;
	>view:first-child{
		position: absolute;
		left: 0;
		color: #168ADE;
	}
}
.content_abx{
	display: flex;
	line-height: 80rpx;
	height: 80rpx;
	border: 1px solid #d9d9d9;
	input{
		height: 80rpx;
	}
	view{
		width: 150rpx;
		text-align: justify;
		text-align-last: justify;
		padding: 0 50rpx;
	}
}
.content_a{
	line-height: 100rpx;
	height: 80rpx;
	background-color: #F5F5F9;
	color: #d9d9d9;
	padding-left: 50rpx;
}
.bz{
	height: 120rpx;
	padding: 20rpx 40rpx;
	border-bottom: 1px solid #d9d9d9;
	margin-bottom: 50rpx;
	textarea{
		height: 120rpx;
	}
}
.tj{
	padding: 0 10rpx;
	button{
		background-color: #118EE9;
		color: white;
	}
}
</style>
